import requests
import test_pb2
import testDanmu_pb2
cookies = {
    'FEED_LIVE_VERSION': 'V8',
    'buvid4': '263695BF-7C46-06E8-0B91-8F0590B7E4D990901-022012422-zfc%2B%2BopW3ru1dt%2FGhhf%2BBQ%3D%3D',
    'buvid_fp_plain': 'undefined',
    'DedeUserID': '491901755',
    'DedeUserID__ckMd5': 'b119362fab0f4c20',
    'CURRENT_BLACKGAP': '0',
    'is-2022-channel': '1',
    'enable_web_push': 'DISABLE',
    'header_theme_version': 'CLOSE',
    '_uuid': 'F3ECD7E8-47CA-4B610-7167-B8A661FA75D952908infoc',
    'buvid3': '0B022DE4-B6CE-6ED3-8C99-76C815727D3971102infoc',
    'b_nut': '1717042170',
    'rpdid': "|(J~R)ulRlRl0J'u~u~kJR|lu",
    'LIVE_BUVID': 'AUTO2517172362602845',
    'hit-dyn-v2': '1',
    'CURRENT_FNVAL': '16',
    'home_feed_column': '4',
    'fingerprint': '1c86bce1f8721b93f87679e751831ab5',
    'buvid_fp': '1c86bce1f8721b93f87679e751831ab5',
    'browser_resolution': '1232-602',
    'CURRENT_QUALITY': '80',
    'bili_ticket': 'eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzQ3Nzg5MDcsImlhdCI6MTczNDUxOTY0NywicGx0IjotMX0.QjgMAq7zD8xng2yYJZFHKn9LxRI4h4ojMTMW71YmLwA',
    'bili_ticket_expires': '1734778847',
    'SESSDATA': '7974f2e5%2C1750072094%2Cdcfb6%2Ac2CjDCLblXZPvW9-rYekUR_ysFhgVUH8n5haiLHsE8u8QpaCIYGBAt2SGGgE0hA_57glcSVmFDb1l4cTlyMWVKT2RadEY4VFFkY2o5R3FQTTd5MnBTNHExSy02dDhITzJMbXk2S05VVDlHenBVRnpvc2VsbnRuYTdKRGMxRzNEM3pOMUFlYlRrNDRBIIEC',
    'bili_jct': '47bdfe46adbe81623dd423bdfe4fb2e8',
    'PVID': '8',
    'b_lsid': '5FEE4ECA_193DC986D73',
    'bp_t_offset_491901755': '1012471736110678016',
    'sid': '6h2jqkgr',
}

headers = {
    'accept': 'application/json, text/plain, */*',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'cache-control': 'no-cache',
    # 'cookie': "FEED_LIVE_VERSION=V8; buvid4=263695BF-7C46-06E8-0B91-8F0590B7E4D990901-022012422-zfc%2B%2BopW3ru1dt%2FGhhf%2BBQ%3D%3D; buvid_fp_plain=undefined; DedeUserID=491901755; DedeUserID__ckMd5=b119362fab0f4c20; CURRENT_BLACKGAP=0; is-2022-channel=1; enable_web_push=DISABLE; header_theme_version=CLOSE; _uuid=F3ECD7E8-47CA-4B610-7167-B8A661FA75D952908infoc; buvid3=0B022DE4-B6CE-6ED3-8C99-76C815727D3971102infoc; b_nut=1717042170; rpdid=|(J~R)ulRlRl0J'u~u~kJR|lu; LIVE_BUVID=AUTO2517172362602845; hit-dyn-v2=1; CURRENT_FNVAL=16; home_feed_column=4; fingerprint=1c86bce1f8721b93f87679e751831ab5; buvid_fp=1c86bce1f8721b93f87679e751831ab5; browser_resolution=1232-602; CURRENT_QUALITY=80; bili_ticket=eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzQ3Nzg5MDcsImlhdCI6MTczNDUxOTY0NywicGx0IjotMX0.QjgMAq7zD8xng2yYJZFHKn9LxRI4h4ojMTMW71YmLwA; bili_ticket_expires=1734778847; SESSDATA=7974f2e5%2C1750072094%2Cdcfb6%2Ac2CjDCLblXZPvW9-rYekUR_ysFhgVUH8n5haiLHsE8u8QpaCIYGBAt2SGGgE0hA_57glcSVmFDb1l4cTlyMWVKT2RadEY4VFFkY2o5R3FQTTd5MnBTNHExSy02dDhITzJMbXk2S05VVDlHenBVRnpvc2VsbnRuYTdKRGMxRzNEM3pOMUFlYlRrNDRBIIEC; bili_jct=47bdfe46adbe81623dd423bdfe4fb2e8; PVID=8; b_lsid=5FEE4ECA_193DC986D73; bp_t_offset_491901755=1012471736110678016; sid=6h2jqkgr",
    'origin': 'https://www.bilibili.com',
    'pragma': 'no-cache',
    'priority': 'u=1, i',
    'referer': 'https://www.bilibili.com/video/BV1tVkwYcESw/?spm_id_from=333.1007.tianma.1-1-1.click&vd_source=d539267ce5d78bdaaafb85b37560df27',
    'sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0',
}

params = {
    'type': '1',
    'oid': '27404206111',
    'pid': '113673188152317',
    'segment_index': '1',
    'pull_mode': '1',
    'ps': '120000',
    'pe': '360000',
    'web_location': '1315873',
    'w_rid': '7f7df0f2ba80d3cbaa35ad5f358584d1',
    'wts': '1734573147',
}

response = requests.get('https://api.bilibili.com/x/v2/dm/wbi/web/seg.so', params=params, cookies=cookies, headers=headers)
# UserData2 = test_pb2.Person()
# print(UserData2.ParseFromString(response.content))
DanmuList =testDanmu_pb2.DmSegMobileReply()
DanmuList.ParseFromString(response.content)
print()